<?php

/**
 * MyApp
 */

class MyApp extends YOU {
	function __construct ()
	{
		parent::__construct();

		// 使用smarty
		$this->tpl = YOU::loadLib('smarty');
		$this->tpl->template_dir    = VIEW_PATH.'/templates/';
		$this->tpl->compile_dir     = VIEW_PATH.'/templates_c/';
		$this->tpl->cache_dir       = CACHE_PATH;
		$this->tpl->left_delimiter  = '{%';
		$this->tpl->right_delimiter = '%}';
		//$this->tpl->cache_lifetime  = CACHE_TIME; //设置缓存时间
		//if (CACHE_ON === true) $this->tpl->caching = true;

		//$this->tpl->assign('url', Helper_Client::getUrl());

		//header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
		//header ("Pragma: no-cache");                          // HTTP/1.0

		// 注册全局变量
		include_once ("helper/request.php");
		$request = new Helper_Request();
		$this->get  = $request->get;
		$this->post = $request->post;


		// 样式路径
		$system_ini = array(
		"img_server" => "static/",

		);

		$baseset_data = $this->db->fetchRow("SELECT * FROM `tbl_baseset`");
		$this->system_ini = $baseset_data;
		$this->system_ini['the_url'] = $_SERVER['REQUEST_URI'];
		$this->tpl->assign("system_ini", $this->system_ini);

		/** 用户类型设置 **/
		$this->user_type_ini = array(
		"staff"    => "老师",
		"student"  => "学生",
		"admin"    => "管理员",
		"repair"   => "维修人员",
		);
		$this->tpl->assign("user_type_ini", $this->user_type_ini);

		// 皮肤设置
		$this->theme_ini = array(
		"blue"   => "蓝色",
		"green"  => "绿色",
		"purple" => "紫色",
		"yellow" => "黄色",
		);
		$this->tpl->assign("theme_ini", $this->theme_ini);

		// 性别显示
		$this->sex_ini = array(
		"1" => "男",
		"0" => "女",
		);
		$this->tpl->assign("sex_ini", $this->sex_ini);

		// 职工类型
		$this->staff_nature_ini = array(
		"1" => "教师",
		"2" => "后勤",
		);
		$this->tpl->assign("staff_nature_ini", $this->staff_nature_ini);
		// 职工性质
		$this->staff_external_ini = array(
		"0" => "教师",
		"1" => "外聘",
		);
		$this->tpl->assign("staff_external_ini", $this->staff_external_ini);
        //外聘性质
        $this->staff_externalx_ini = array(
            "0" => "教师",
            "1" => "后勤",
        );
        $this->tpl->assign("staff_externalx_ini", $this->staff_externalx_ini);
		// 学历显示
		$this->education_ini = array(
		//"1" => "专科以下",
		"2" => "专科",
		"3" => "本科",
		//"4" => "研究生",
		//"5" => "研究生以上",
		"6" => "高中",
		"7" => "中专",
		"8" => "硕士研究生",
		"9" => "博士研究生",
		);
		$this->tpl->assign("education_ini", $this->education_ini);
		// 党员显示
		$this->party_ini = array(
		"0" => "群众",
		"1" => "中共党员",
		"2" => "中共预备党员",
        "3" => "共青团员",
		);
		$this->yes_ini = array(
		"0" => "否",
		"1" => "是",
		);
		$this->tpl->assign("yes_ini", $this->yes_ini);
		// 职称显示
		$this->position_ini = array(
		"1" => "未定级",
		"2" => "一级教师",
		"3" => "二级教师",
		"4" => "三级教师",
		"5" => "高级教师",
		"6" => "正高级教师",
		);
		$this->tpl->assign("position_ini", $this->position_ini);
		// 在职标记显示
		$this->sign_ini = array(
		"0" => "在职",
		"1" => "离职",
		"2" => "退休",
		"3" => "借出",
		"4" => "调回",
		"5" => "解聘",
		"6" => "聘用",
		);
		//考核
		$this->assess_ini = array(

		"1" => "优秀",
		"2" => "合格",
		"3" => "不及格",
		);
		$this->tpl->assign("assess_ini", $this->assess_ini);
		// 在职标记显示
		$this->position_type = array(
		"0" => "班主任",
		"1" => "级长",
		"2" => "副级长",
		"3" => "组长",
		"4" => "副组长",
		);
		$this->tpl->assign("position_type", $this->position_type);
		// 计划、总结部门
		$this->department_type = array(
		"0" => "校长室",
		"1" => "教务处",
		"2" => "教研室",
		"3" => "政教处",
		"4" => "团支部",
		"5" => "总务处",
		);
		$this->tpl->assign("summarize_type", $this->summarize_type);
		// 残疾
		$this->disability_ini = array(
		"0" => "无",
		"1" => "视力残疾",
		"2" => "听力残疾",
		"3" => "智力残疾",
		"4" => "其他残疾",
		);
		$this->tpl->assign("disability_ini", $this->disability_ini);
		// 户口
		$this->registered_ini = array(
		"1" => "农村",
		"2" => "城市",
		);
		$this->tpl->assign("registered_ini", $this->registered_ini);

		// 残疾
		$this->mode_ini = array(
		"1" => "寄宿生",
		"0" => "走读生",
		);
		$this->tpl->assign("mode_ini", $this->mode_ini);

		// 类别
		$this->classes_ini = array(
		"0" => "走读生",
		"1" => "借读生",
		"2" => "统招生",
		"3" => "择校生",
		);
		//分类
		$this->state_ini = array(
		"0" => "空",
		"1" => "插班生",
		"2" => "留级生",
		"3" => "复读生",
		"4" => "其他",
		);
		$this->tpl->assign("state_ini", $this->state_ini);
		//教育等级
		$this->etype_ini = array(
		"0" => "完中",
		"1" => "小学",
		"2" => "初中",
		"3" => "高中",
		);

		$this->tpl->assign("classes_ini", $this->classes_ini);
		// 地区类别
		$this->area_ini = array(
		"0" => "城乡结合",
		"1" => "城",
		"2" => "乡",
		);
		$this->tpl->assign("area_ini", $this->area_ini);
		// 班级级别
		$this->class_level = array(
		"0" => "",
		"1" => "文科",
		"2" => "理科",
		"3" => "体育",
		"4" => "艺术",
		);
		$this->tpl->assign("class_level", $this->class_level);
		// 字体名称
		$this->style_name = array(
		"0" => "宋体",
		"1" => "黑体",
		"2" => "楷体",
		);
		$this->tpl->assign("style_name", $this->style_name);
		// 字体加粗
		$this->style_overstriking = array(
		"0" => "无",
		"1" => "加粗",
		);
		$this->tpl->assign("style_overstriking", $this->style_overstriking);
		// 字体加粗展示
		$this->style_overstrikings = array(
		"0" => "无",
		"1" => "bold",
		);
		$this->tpl->assign("style_overstrikings", $this->style_overstrikings);
		// 字体斜体
		$this->style_italic = array(
		"0" => "无",
		"1" => "斜体",
		);
		$this->tpl->assign("style_italic", $this->style_italic);
		// 字体斜体展示
		$this->style_italics = array(
		"0" => "无",
		"1" => "italic",
		);
		$this->tpl->assign("style_italics", $this->style_italics);
		// 字体颜色
		$this->style_color = array(
		"black" => "black",
		"red"	=> "red",
		"green" => "green",
		);
		$this->tpl->assign("style_color", $this->style_color);


		// 计划总结
		$this->summarize_type = array(
		"1" => "工作计划",
		"2" => "工作总结",
		"3" => "工作计划",
		"4" => "工作总结",
		"5" => "工作计划",
		"6" => "工作总结",
		"7" => "工作计划",
		"8" => "工作总结",
		"9" => "工作计划",
		"10" => "工作总结",
		);

		// 通知审核
		$this->inform_judge = array(
		"0" => "未审核",
		"1" => "通过",
		"2" => "未通过",
		);
		$this->tpl->assign("inform_judge", $this->inform_judge);
		// 学期
		$this->semester_name = array(
		"1" => "第一学期",
		"2" => "第二学期",
		);
		$this->tpl->assign("semester_name", $this->semester_name);
		// 课程表单双周
		$this->syllabus_week = array(
		"1" => "单周",
		"2" => "双周",
		);
		$this->tpl->assign("syllabus_week", $this->syllabus_week);
		// 惩罚、奖励
		$this->award_type = array(
		"1" => "奖励",
		"2" => "违规",
		);
		$this->tpl->assign("award_type", $this->award_type);
		// 星期
		$this->week_ini = array(
		"1" => "星期一",
		"2" => "星期二",
		"3" => "星期三",
		"4" => "星期四",
		"5" => "星期五",
		"6" => "星期六",
		"7" => "星期日",
		);
		$this->tpl->assign("week_ini", $this->week_ini);
		// 星期数值
		$this->week_num = array(
		"1" => "1",
		"2" => "2",
		"3" => "3",
		"4" => "4",
		"5" => "5",
		);
		$this->tpl->assign("week_num", $this->week_num);
		// 月份
		$this->month_ini = array(
		"1" => "一月",
		"2" => "二月",
		"3" => "三月",
		"4" => "四月",
		"5" => "五月",
		"6" => "六月",
		"7" => "七月",
		"8" => "八月",
		"9" => "九月",
		"10" => "十月",
		"11" => "十一月",
		"12" => "十二月",
		);
		$this->tpl->assign("month_ini", $this->month_ini);

		// 请假无需扣除原因
		$this->free_ini = array(
		"1" => "公假",
		"2" => "婚假",
		"3" => "病假",
		"4" => "事假",
		"5" => "产假",
		"6" => "丧假",
		);
		$this->tpl->assign("free_ini", $this->free_ini);

		// 值日部分
		$this->duty_section_ini = array(
		"1" => "上午",
		"2" => "下午",
		);

		// 特殊课堂应用类型
		$this->special_type_ini = array(
		"school" => "全校",
		"grade"  => "指定年级",
		"class"  => "指定班级",
		);
		$this->tpl->assign("special_type_ini", $this->special_type_ini);


		// 文章名称
		$this->manage_name = array(
		"1"  => "班子建设",
		"2"  => "制度建设",
		"3"  => "党务资料",
		"4"  => "党费收缴",
		"5"  => "班子建设",
		"6"  => "制度建设",
		"7"  => "工会事务",
		"8"  => "工会费用",
		"9"  => "安全制度",
		"10" => "活动资料",
		"11" => "应急预案",
		"12" => "安全检查资料",
		"13" => "家委会名册",
		"14" => "家长志愿者",
		"15" => "家长会",
		"16" => "家委会活动",
		"17" => "竞聘上岗",
		"18" => "教研计划进度表",
		"19" => "评优评先",
		"20" => "复习计划",
		"21" => "教学工作手册",
		"22" => "示范课教案",
		"23" => "班主任经验交流",
		"24" => "团支部活动",
		"25" => "工作制度",
		"26" => "工作职责",
		"27" => "专项检查",
		);
		$this->tpl->assign("manage_name", $this->manage_name);
		// 通知名称
		$this->inform_name = array(
		"1" => "事务交代",
		"2" => "公示",
		);
		$this->tpl->assign("inform_name", $this->inform_name);
		// 报修状态
		$this->main_type = array(
		"1" => "报修",
		"2" => "派单",
		"3" => "完成",
		);
		// 申购状态
		$this->shop_type = array(
		"1" => "申购",
		"2" => "派单",
		"3" => "完成",
		);
		$this->tpl->assign("shop_type", $this->shop_type);
		// 报修、申购结算
		$this->is_show = array(
		"1" => "已结",
		"2" => "未结",
		);
		$this->tpl->assign("is_show", $this->is_show);
		// 考试分类
		$this->exam_type_ini = array(
		"1" => "单元考",
		"2" => "月考",
		"3" => "季度考",
		"4" => "大考",
		);
		$this->tpl->assign("exam_type_ini", $this->exam_type_ini);
		// 成绩形式
		$this->score_type_ini = array(
		"1" => "分数",
		"2" => "等第",
		);
		$this->tpl->assign("score_type_ini", $this->score_type_ini);

		// 优良率分数段设置
		$this->score_section_ini = array(
		"1" => "优秀",
		"2" => "良好",
		"3" => "优良",
		"4" => "合格",
		"5" => "及格",
		"6" => "不及格",
		"7" => "极差",
		);
		$this->tpl->assign("score_section_ini", $this->score_section_ini);

		// 学生评语、日常记事
		$this->show_name = array(
		"1" => "期末学生评语",
		"2" => "学生日常记事",
		);
		$this->tpl->assign("show_name", $this->show_name);
		// 学生评语、日常记事->页面展示内容
		$this->show_content = array(
		"1" => "评语内容",
		"2" => "日常记事",
		);
		$this->tpl->assign("show_content", $this->show_content);

		// 不记常规补贴项目
		$this->pay_unitem = array(
		"1" => "班主任",
		"2" => "全勤",
		"3" => "值日",
		"4" => "作业",
		"5" => "课时",
		"6" => "代课",
		"7" => "超课时",
		);
		$this->tpl->assign("pay_unitem", $this->pay_unitem);

		$this->prize_ini = array(
		"1" => "集体获奖",
		"2" => "教师获奖",
		"3" => "课件获奖",
		"4" => "课例获奖",
		"5" => "学生获奖",
		"6" => "论文著作",
		);
		$this->tpl->assign("prize_ini", $this->prize_ini);




		// 获取上一周本周开始、结束时间
		$date=date('Y-m-d');  //当前日期
		$first=1; //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
		$w=date('w',strtotime($date));  //获取当前周的第几天 周日是 0 周一到周六是 1 - 6
		$now_start=date('Y-m-d',strtotime("$date -".($w ? $w - $first : 6).' days')); //获取本周开始日期，如果$w是0，则表示周日，减去 6 天
		$now_end=date('Y-m-d',strtotime("$now_start +6 days"));  //本周结束日期
		$last_start=date('Y-m-d',strtotime("$now_start - 7 days"));  //上周开始日期
		$last_end=date('Y-m-d',strtotime("$now_start - 1 days"));  //上周结束日期
		$this->now_start =$now_start;
		$this->now_end =$now_end;
		$this->last_start =$last_start;
		$this->last_end =$last_end;
		$this->tpl->assign("now_start", $this->now_start);
		$this->tpl->assign("now_end", $this->now_end);
		$this->tpl->assign("last_start", $this->last_start);
		$this->tpl->assign("last_end", $this->last_end);
		// ----------------结束--------//



		// 教师档案字段
		$this->teacher_record_ini = array(
		//		"0"  => array("name" => "staff_name",      "title" => "姓名"),
		//		"1"  => array("name" => "staff_number",    "title" => "编号"),
		//		"2"  => array("name" => "staff_sex",       "title" => "性别"),
		//		"3"  => array("name" => "staff_position",  "title" => "职称"),
		//		"4"  => array("name" => "staff_tel",       "title" => "电话号码"),
		//		"5"  => array("name" => "staff_skype",     "title" => "内部电话"),
		//		"6"  => array("name" => "staff_education", "title" => "学历"),
		//		"7"  => array("name" => "staff_party",     "title" => "党员"),
		//		"8"  => array("name" => "staff_card",      "title" => "身份证号"),
		//		"9"  => array("name" => "start_time",  "title" => "参加工作时间"),
		//		"10" => array("name" => "end_time",      "title" => "到校工作时间"),
		//		"11" => array("name" => "staff_birth",     "title" => "出生日期"),
		//		"12" => array("name" => "staff_entry",     "title" => "入职时间"),
		//		"13" => array("name" => "staff_nature",    "title" => "员工性质"),
		//		"14" => array("name" => "staff_assess",    "title" => "年度考核"),
		//		"15" => array("name" => "staff_sign",      "title" => "在职标记"),
		//		"16" => array("name" => "staff_img",       "title" => "相片"),
		//		"17" => array("name" => "staff_file",      "title" => "附件"),
		"0"  => array("title"=>"姓名","name"=>"staff_name"),
		"1"  => array("title"=>"曾用名","name"=>"staff_usedname"),
		"2"  => array("title"=>"性别"
		,"name"=>"staff_sex"),
		"3"  => array("title"=>"教职工号"
		,"name"=>"staff_number"),
		"4"  => array("title"=>"身份证件类型"
		,"name"=>"staff_idtype"),
		"5"  => array("title"=>"国籍/地区"
		,"name"=>"staff_area"),
		"6"  => array(
		"title"=>"出生日期"
		,"name"=>"staff_birth"),
		"7"  => array("title"=>"身份证件号"
		,"name"=>"staff_card"),
		"8"  => array(
		"title"=>"籍贯"
		,"name"=>"staff_home"),
		"9"  => array("title"=>"出生地"
		,"name"=>"staff_city"),
		"10" => array(
		"title"=>"民族"
		,"name"=>"staff_nation"),
		"11" => array("title"=>"政治面貌"
		,"name"=>"staff_party"),
		"12" => array(
		"title"=>"婚姻状况"
		,"name"=>"staff_marry"),
		"13" => array("title"=>"健康状况"
		,"name"=>"staff_health"),
		"14" => array(
		"title"=>"参加工作年月"
		,"name"=>"start_time"),
		"15" => array("title"=>"进本校年月"
		,"name"=>"end_time"
		),
		"16" => array(
		"title"=>"教职工来源"
		,"name"=>"staff_orignal"),
		"17" => array("title"=>"教职工类别"//external
		,"name"=>"staff_classes"),
		"18"  => array("title"=>"是否在编"
		,"name"=>"staff_nature"),
		"19"  => array("title"=>"用人形式"
		,"name"=>"staff_style"),
		"20"  => array("title"=>"签订合同情况"
		,"name"=>"staff_signed"),
		"21"  => array("title"=>"是否全日制师范类专业毕业"
		,"name"=>"staff_normal"),
		"22"  => array("title"=>"是否受过特教专业培养培训"
		,"name"=>"staff_skill"),
		"23"  => array("title"=>"是否有特殊教育从业证书"
		,"name"=>"staff_certificate"),
		"24"  => array(
		"title"=>"信息技术应用能力"
		,"name"=>"staff_info"),
		"25"  => array("title"=>"是否属于免费（公费）师范生"
		,"name"=>"staff_free"),
		"26"  => array("title"=>"是否参加基层服务项目"
		,"name"=>"staff_basic"),
		"27"  => array("title"=>"参加基层项目服务起始年月"
		,"name"=>"staff_basic_start"),
		"28" => array("title"=>"参加基层项目服务结束年月"
		,"name"=>"staff_basic_end"),
		"29" => array("title"=>"是否特级教师"
		,"name"=>"staff_super"),
		"30" => array(
		"title"=>"是否县级及以上骨干教师"
		,"name"=>"staff_bone"),
		"31" => array("title"=>"是否心理健康教育教师"
		,"name"=>"staff_mental"),
		//            "32" => array("title"=>"人员状态"
		//            ,"name"=>"staff_sign"),
		"33" => array("title"=>"调动时间"
		,"name"=>"staff_ctime"),
		"34" => array("title"=>"入党日期"
		,"name"=>"staff_party_date"),
		//            "35" => array("title"=>"入党日期"
		//            ,"name"=>"staff_party_date"),
		"35"  => array("title"=>"家庭住址"
		,"name"=>"staff_addr"),
		"36"  => array("title"=>"固定电话"
		,"name"=>"staff_fix"),
		"37"  => array("title"=>"手机号码"
		,"name"=>"staff_tel"),
		"38"  => array("title"=>"工作职称"
		,"name"=>"staff_position"),
		"39"  => array("title"=>"最高学历"
		,"name"=>"staff_education"),
		"40"  => array(
		"title"=>"毕业院校"
		,"name"=>"staff_school"),
		"41"  => array("title"=>"毕业时间"
		,"name"=>"staff_graduate_time"),
		"42"  => array("title"=>"备注"
		,"name"=>"staff_remark"),
		"43" => array("title"=>"人员状态"
		,"name"=>"staff_zhuang"),
		);
		$this->tpl->assign("teacher_record_ini", $this->teacher_record_ini);

		//  学生档案字段
		$this->student_record_ini = array(
		"0"   => array("name" => "student_name",       "title" => "姓名"),
		"1"   => array("name" => "student_school",        "title" => "学籍号"),
		"2"   => array("name" => "student_card",     "title" => "身份证件号"),
		"3"   => array("name" => "student_sex",         "title" => "性别"),
		"4"   => array("name" => "student_no",        "title" => "学号"),
		"5"   => array("name" => "student_register",      "title" => "户口状况"),
		"6"   => array("name" => "student_office",       "title" => "所在派出所"),
		"7"   => array("name" => "student_islocal",        "title" => "是否本区"),
		"8"   => array("name" => "student_over",       "title" => "是否超生"),
		"9"   => array("name" => "student_variation",     "title" => "学籍变动"),
		"10"  => array("name" => "student_ctime",   "title" => "变动时间"),
		"11"  => array("name" => "student_remarks",       "title" => "备注"),
		"12"  => array("name" => "student_native",      "title" => "籍贯"),
		"13"  => array("name" => "student_nation",      "title" => "民族"),
		"14"  => array("name" => "student_addr",     "title" => "家庭住址"),
		"15"  => array("name" => "student_tel",   "title" => "联系电话"),
		"16"  => array("name" => "student_sname",	   "title" => "学校名称"),
		"17"  => array("name" => "student_snumber",       "title" => "学校标识码"),
		"18"  => array("name" => "student_birth",    "title" => "出生日期"),
		"19"  => array("name" => "student_city",       "title" => "出生地"),
		"20"  => array("name" => "student_country",      "title" => "国籍地区"),
		"21"  => array("name" => "student_idtype", "title" => "身份证件类型"),
		"22"  => array("name" => "grade_id",      "title" => "年级"),
		"23"  => array("name" => "student_china",  "title" => "港澳台侨外"),
		"24"  => array("name" => "class_id", "title" => "班级"),
		"25"  => array("name" => "student_politics",   "title" => "政治面貌"),
		"26"  => array("name" => "student_health",       "title" => "健康状态"),
		"27"  => array("name" => "student_register_place",      "title" => "户口所在地"),
		"28"  => array("name" => "student_registered",      "title" => "户口性质"),
		"29"  => array("name" => "student_start_time",     "title" => "入学年月"),
		"30"  => array("name" => "student_now_addr",   "title" => "现住址"),
		"31"  => array("name" => "student_way",	   "title" => "入学方式"),
		"32"  => array("name" => "student_tel_addr",       "title" => "通讯地址"),
		"33"  => array("name" => "student_home_addr",    "title" => "家庭住址"),
		"34"  => array("name" => "student_mail",       "title" => "邮政编码"),
		"35"  => array("name" => "is_work",      "title" => "是否进城务工人员子女"),
		"36"  => array("name" => "is_alone", "title" => "是否独生子女"),
		"37"  => array("name" => "is_study",      "title" => "是否受过学前教育"),
		"38"  => array("name" => "is_stay",  "title" => "是否留守儿童"),
		"39"  => array("name" => "is_help", "title" => "是否需要申请资助"),
		"40"  => array("name" => "is_martyr",   "title" => "是否烈士子女"),
		"41"  => array("name" => "is_subsidy",       "title" => "是否享受一补"),
		"42"  => array("name" => "student_mode",      "title" => "就读方式"),
		"43"  => array("name" => "is_left",      "title" => "是否孤儿"),
		"44"  => array("name" => "student_help_no",     "title" => "学籍辅号"),
		"45"  => array("name" => "student_class_no",   "title" => "班内学号"),
		"46"  => array("name" => "student_from",	   "title" => "学生来源"),
		"47"  => array("name" => "student_read",       "title" => "随班就读"),
		"48"  => array("name" => "student_disability",    "title" => "残疾类型"),
		"49"  => array("name" => "student_parent",       "title" => "家庭成员姓名"),
		"50"  => array("name" => "student_home_relation",      "title" => "家庭成员关系"),
		"51"  => array("name" => "student_home_work", "title" => "家庭成员工作单位"),
		"52"  => array("name" => "student_parent_addr",      "title" => "家庭成员现住址"),
		"53"  => array("name" => "student_ptel",  "title" => "家庭成员联系电话"),
		"54"  => array("name" => "student_parent_city", "title" => "家庭成员户口所在地"),

		);
		$this->tpl->assign("student_record_ini", $this->student_record_ini);

		// 英文下标定义
		$this->letter_ini = array(
		"0"  => "A",
		"1"  => "B",
		"2"  => "C",
		"3"  => "D",
		"4"  => "E",
		"5"  => "F",
		"6"  => "G",
		"7"  => "H",
		"8"  => "I",
		"9"  => "J",
		"10" => "K",
		"11" => "L",
		"12" => "M",
		"13" => "N",
		"14" => "O",
		"15" => "P",
		"16" => "Q",
		"17" => "R",
		"18" => "S",
		"19" => "T",
		"20" => "U",
		"21" => "V",
		"22" => "W",
		"23" => "X",
		"24" => "Y",
		"25" => "Z",
		);

		$this->time = time();
		$this->now  = date("Y-m-d H:i:s");

		// 使用auth类
		YOU::loadLib('auth', "", '0');
		$this->auth = new AUTH($this->db, "tbl_user");
		$this->auth->tb_username  = "user_name";
		$this->auth->tb_password  = "user_password";
		$this->auth->tb_id        = "user_id";
		// 用户权限等大量字符不存cookie
		$this->auth->field        = array("user_id", "user_name", "user_type", "type_id");
		$this->auth->key_prefix   = "3e8123087dcdba180f21e3b6f1888888";
		$this->auth->cookie_key   = "WY_SCHOOL";
		$this->auth->cookie_life  = "";

		// 验证是否登录
		$this->user = $this->auth->isLogin();

		if ( !in_array($_GET['a'], array("user.login", "install.start", "install.config", "install.success")) ){
			if (empty($this->user['user_id'])) {
				Helper_Client::reurl("index.php?a=user.login");exit();
			}

			// 得到用户其他信息
			@$this->model->user = YOU::loadModel('user');
			$user_data =  $this->model->user->getInfo($this->user['user_id'], "user_group,user_pms");
			$this->user = @array_merge($this->user, $user_data);



		}



		$this->user['type_note'] = $this->user_type_ini[$this->user['user_type']];
		switch ($this->user['user_type']){
			case "staff":
				$this->model->staff   = YOU::loadModel('staff');
				$staff_data = $this->model->staff->getInfo($this->user['type_id']);
				$this->user = @array_merge($this->user, $staff_data);
				$this->user['user_title'] = $staff_data['staff_name'];
				break;
			case "student":
				$this->model->student = YOU::loadModel('student');
				$student_data = $this->model->student->getInfo($this->user['type_id']);
				$this->user = @array_merge($this->user, $student_data);
				$this->user['user_title'] = $student_data['student_name'];
				break;
			case "repair":
				$repair_data = $this->db->fetchRow("select * from `tbl_maince` WHERE maince_id = {$this->user['type_id']}");
				$this->user['user_title'] = $repair_data['maince_name'];
				break;
			case "shop":
				$shop_data = $this->db->fetchRow("select * from `tbl_shops` WHERE shops_id = {$this->user['type_id']}");
				$this->user['user_title'] = $shop_data['shops_name'];
				break;
			case "admin":
				$this->user['user_title'] = $this->user['user_name'];
				break;
			default:
				break;
		}

		// 用户信息传递给模板
		$this->tpl->assign("user_auth", $this->user);
		//var_dump($this->user);

		$this->model->menu = YOU::loadModel('menu');
		// 当前方法
		if (isset($_GET['a']) && $_GET['a'] != ""){
			$this->model->menu->act = $_GET['a'];
		}

		$this->tpl->assign("a", $_GET['a']);
		// 递归得到当前方法的id和各父id
		$menu_data = $this->model->menu->getInfoByFun($this->model->menu->act);
		if (!empty($menu_data)){
			$menu_id = $menu_data['menu_id'];
			$this->model->menu->farr[] = $menu_id;
			$this->model->menu->getFid($menu_id);
			$this->tpl->assign("act_title", $menu_data['menu_name']);

			// 检测当前访问方法id是否位于用户权限
			$upms = @unserialize($this->user['user_pms']);

			if (@in_array($menu_id, $upms) === false){
				exit("没有权限");
			}



		}

		// 左侧菜单
		$this->model->menu->arr = $this->model->menu->getFlist("show_left", $this->user['user_pms']);
		$this->model->menu->stt = "";
		$this->model->menu->act = strtolower($_GET['a']);
		$this->model->menu->tree_left(0);

		$menu_left = $this->model->menu->stt;
		$this->tpl->assign("menu_left", $menu_left);

		// 面包屑
		$menu_nav = $this->model->menu->getNav();
		$this->tpl->assign("menu_nav", $menu_nav);

		// 新邮件数
		$row = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_mail` WHERE mail_to='{$this->user['user_id']}' AND is_read='0' AND status='1'");
		$mail_newc = (int)$row['count'];
		$this->tpl->assign("mail_newc", $mail_newc);

		// 最新邮件列表 5 条
		$mail_newls = $this->db->fetchAll("SELECT * FROM `tbl_mail` WHERE mail_to='{$this->user['user_id']}' ORDER BY mail_id DESC LIMIT 0,5");

		// 通知部门id
		foreach($mail_newls as $key => $value){
			$mail_newls[$key]['create_time'] =date('m-d H:i',strtotime($value['create_time']));
			// 发件人
		
			$row  = $this->db->fetchRow("SELECT * FROM `tbl_user` WHERE user_id='{$value['mail_from']}' ");
			$staff_data = $this->db->fetchRow("SELECT * FROM `tbl_staff` WHERE staff_id={$row['type_id']}");
			$mail_newls[$key]['staff_name'] = $staff_data['staff_name'];
		}
		$this->tpl->assign("mail_newls", $mail_newls);


		// 新通知数
		$row = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_inform` WHERE staff_to='{$this->user['user_id']}' AND inform_read='0' AND status='1'");
		$notice_newc = (int)$row['count'];
		$this->tpl->assign("notice_newc", $notice_newc);
		// 最新通知列表 5 条
		$notice_newls = $this->db->fetchAll("SELECT inform_id,inform_title FROM `tbl_inform` WHERE staff_to='{$this->user['user_id']}'  ORDER BY inform_id DESC LIMIT 0,5");
		$this->tpl->assign("notice_newls", $notice_newls);
		
		// 通知全部 ----------------------------------------------------------------------------开始
		// 前三行 上级通知
		$user_id = $this->user['user_id'];
		$num = 3;
		$time = date('Y-m-d H:i',time());
		
		
		$inform_all_three =  $this->db->fetchAll(" SELECT * FROM `tbl_notice` AS a,
  `tbl_notice_read` AS b WHERE a.notice_id=b.notice_id AND a.notice_type IN (2,3) AND a.is_show IN (1,3) AND b.read_to ='{$user_id}' AND start_time <='{$time}' ORDER BY b.is_read ASC,a.notice_id DESC LIMIT 0,{$num} ");
		foreach($inform_all_three  as $key => $value){
			$department_data = $this->db->fetchRow("SELECT * FROM `tbl_department` WHERE department_id={$value['department_id']}");
			$inform_all_three[$key]['department_name'] = $department_data['department_name'];
			$inform_all_three[$key]['create_time'] =date('m-d H:i',strtotime($value['create_time']));
		}
		
		// 合
		$inform_all_three_count = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_notice` AS a,`tbl_notice_read` AS b WHERE a.notice_id=b.notice_id AND a.notice_type IN (2,3) AND a.is_show IN (1,3) AND b.read_to ='{$user_id}' AND start_time <='{$time}' AND b.is_read= '0' ");
		
		// 后二行公告
		// 公告 条数
		//$inform_type=2;
		
		$notice_type = 1;
		$num = 2;
		
		
		$inform_all_two = $this->db->fetchAll("SELECT * FROM `tbl_notice` AS a,`tbl_notice_read` AS b  WHERE a.notice_id=b.notice_id AND  b.read_to ='{$user_id}' AND a.notice_type = '{$notice_type}'  ORDER BY b.is_read ASC,a.notice_id DESC LIMIT 0,{$num}");
		foreach($inform_all_two  as $key => $value){
			$department_data = $this->db->fetchRow("SELECT * FROM `tbl_department` WHERE department_id={$value['department_id']}");
			$inform_all_two[$key]['department_name'] = $department_data['department_name'];
			$inform_all_two[$key]['create_time'] =date('m-d H:i',strtotime($value['create_time']));
		}
	
		
		// 合
		$inform_all_two_count = $this->db->fetchRow("SELECT COUNT(1) AS count FROM `tbl_notice` AS a,`tbl_notice_read` AS b  WHERE a.notice_id=b.notice_id AND  b.read_to ='{$user_id}' AND a.notice_type = '{$notice_type}' AND b.is_read = '0'");
		
		
		// 总合
		$notice_count = $inform_all_three_count['count']+$inform_all_two_count['count'];
		

		$this->tpl->assign("inform_all_three", $inform_all_three);
		$this->tpl->assign("inform_all_two", $inform_all_two);
		$this->tpl->assign("notice_count", $notice_count);
	
		// 通知全部 ----------------------------------------------------------------------------结束
		// 左侧时间显示
		$this->week_en = array(
		"0" => "星期日",
		"1" => "星期一",
		"2" => "星期二",
		"3" => "星期三",
		"4" => "星期四",
		"5" => "星期五",
		"6" => "星期六",
		);
		$week = date("w");
		$time_left = array(
		"month" => date("Y年n月"),
		"day"   => date("d"),
		"week"  => $this->week_en[date("w")],
		);
		$this->tpl->assign("time_left", $time_left);

	}

}


?>